package com.cc.crm.service.impl;

import com.cc.crm.mapper.CustomerVisitMapper;
import com.cc.crm.pojo.CustomerVisit;
import com.cc.crm.service.CustomerVisitService;
import com.cc.crm.vo.CustomerVisitVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program:
 * @ClassName:
 * @description:
 * @author: zgc
 * @date:
 * @Version 1.0
 **/
@Service
public class CustomerVisitServiceImpl implements CustomerVisitService {
    @Resource
    private CustomerVisitMapper customerVisitMapper;

    @Override
    public int insertVisit(CustomerVisit customerVisit) {
        return customerVisitMapper.insertVisit(customerVisit);
    }

    @Override
    public int updateVisit(CustomerVisit customerVisit) {
        return customerVisitMapper.updateVisit(customerVisit);
    }

    @Override
    public PageInfo<CustomerVisit> selectVisit(CustomerVisitVo customerVisitVo) {
        if (customerVisitVo.getPageNum()!=null && customerVisitVo.getPageSize()!=null){
            PageHelper.startPage(customerVisitVo.getPageNum(),customerVisitVo.getPageSize());
        }
        List<CustomerVisit> customers = customerVisitMapper.selectVisit(customerVisitVo);
        
        PageInfo<CustomerVisit> pageInfo = new PageInfo<>(customers);
        return pageInfo;
    }
}
